
from base.base import Base


# ----------------权限管理----------------

class page_permissions_manage(Base):
    

    # 模糊查询
    def fuzzy_query(self,name):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        self.logger.info("点击权限管理")
        self.send_keys('fuzzy_query',name)
        self.logger.info("输入权限名称")
        self.keys_enter('fuzzy_query')
        self.logger.info("点击查询按钮")

    # 精确查询
    def accurate_query(self,permission_id):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        self.logger.info("点击权限管理")
        self.send_keys('accurate_query',permission_id)
        self.logger.info("输入权限标识")
        self.keys_enter('accurate_query')
        self.logger.info("点击查询按钮")

    # 添加权限
    def add_permission(self,permission_name,permission_id,permissions_description):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        self.logger.info("点击权限管理")
        self.click('add_permissions')
        self.logger.info('点击添加权限')
        self.send_keys('permission_name',permission_name)
        self.logger.info("输入权限名称")
        self.send_keys('permission_identification',permission_id)
        self.logger.info("输入权限标识")
        self.send_keys('permissions_description',permissions_description)
        self.logger.info("输入权限描述")
        self.click('save_button')
        self.logger.info("点击保存按钮")
        self.click('add_ok')

    # 删除权限
    def delete_permission(self):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        self.logger.info("点击权限管理")
        self.click('permission_delete')
        self.logger.info("点击删除按钮")
        self.click('queren')
        self.logger.info("点击确认按钮")
        self.click('del_ok')

    # 编辑权限
    def edit_permission(self,permission_name,permissions_description):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        self.logger.info("点击权限管理")
        self.click('permissions_modify')
        self.logger.info("点击编辑按钮")
        self.send_keys('modify_name',permission_name)
        self.logger.info("输入权限名称")
        self.send_keys('modify_desc',permissions_description)
        self.logger.info("输入权限描述")
        self.click('save_modify')
        self.logger.info("点击保存按钮")
        self.click('up_ok')

    # 获取权限标识
    def get_permission_id(self):
        self.switch_node('permissions_manages')
        self.click('permission_manage')
        return self.text('get_permission_id')